home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #2 / Monster Media No. 2 (Monster Media)(1994).ISO / utils2 / pwrbat22.zip / CALC.PWR < prev    next >
Text File  |  1994-05-18  |  12KB  |  352 lines

  1.   Variable    Work,255
  2.   Variable    Month,2
  3.   Variable    Day,2
  4.   Variable    Year,4
  5.   Variable    Time,11
  6.   Variable    CurClr,3
  7.   Variable    Normal,1,1
  8.   Variable    On,1,1
  9.   Variable    Off,1,0
  10.   Variable    Zeros,18,'000000000000000000'
  11.   Variable    Spaces,18,'                  '
  12.   Variable    Cmds1,100,'224Number Of Decimals 2332   224Memory Cell           233Esc224 Exit'
  13.   Variable    Cmds2,100,'233+224  Add  233-224 Subtract  233*224 Multiply   233/224 Divide  233F1224 Decimals'
  14.   Variable    Cmds3,100,'233F2224 Clr Total   233F3224 Clr Memory  233F4224 Recall Memory'
  15.   Variable    Cmds4,100,'233F5224 Add to Mem  233F6224 Sub fr Mem  233F7224 Stor to Mem '
  16.   Variable    Plus,1,#43
  17.   Variable    Minus,1,#45
  18.   Variable    Mult,1,#42
  19.   Variable    Div,1,#47
  20.   Variable    F1,1,#59
  21.   Variable    F2,1,#60
  22.   Variable    F3,1,#61
  23.   Variable    F4,1,#62
  24.   Variable    F5,1,#63
  25.   Variable    F6,1,#64
  26.   Variable    F7,1,#65
  27.   Variable    Esc,1,#27
  28.  
  29.   Variable    Mem1,18,0
  30.   Variable    Mem2,18,0
  31.   Variable    Mem3,18,0
  32.   Variable    Mem4,18,0
  33.   Variable    Total,18,0
  34.   Variable    Entry,18,0
  35.   Variable    RtnCode,2
  36.   Variable    NumDecs,2,2
  37.   Variable    CtrLgth,2
  38.   Variable    DecLoc,2
  39.   Variable    DecToAdd,2
  40.   Variable    Func,1,' '
  41.   Variable    Spec,1
  42.  
  43.   ?Color      Work,Work,CurClr
  44.   Cursor      Off
  45.   EnhanClr    On
  46.   Clear       135,,'░'
  47.   Box1        1,1,57,3,228                      ;Title box
  48.   Box1        1,20,57,25,228                    ;msg box at bottom
  49.   Box1        58,1,80,25,240                    ;"tape" box
  50.   Box1        3,5,27,7,158                      ;mem 1 box
  51.   Box1        31,5,55,7,158                     ;mem 2 box
  52.   Box1        3,10,27,12,158                    ;mem 3 box
  53.   Box1        31,10,55,12,158                   ;mem 4 box
  54.   Box1        18,15,40,17,160                   ;entry box
  55.   WriteAt     17,2,'The PowerBatch Calculator',228
  56.   ?Date       Work,Month,Day,Year
  57.   Concat      Work,Month,'/',Day,'/',Year
  58.   WriteAt     3,3,Work,228
  59.   WriteAt     11,5,'Memory 1',159
  60.   WriteAt     39,5,'Memory 2',159
  61.   WriteAt     11,10,'Memory 3',159
  62.   WriteAt     39,10,'Memory 4',159
  63.   WriteAt     27,15,'Entry',160
  64.   WriteAt     3,21,Cmds1
  65.   WriteAt     3,22,Cmds2
  66.   WriteAt     3,23,Cmds3
  67.   WriteAt     3,24,Cmds4
  68.   GoTo        DispMem
  69.  
  70. Label     NextCalc
  71.   SetVar      DecToAdd,NumDecs
  72.   LocStr      '.',Entry,1,DecLoc                ;force a decimal
  73.   Compare     DecLoc,0,Dec1
  74.   Concat      Entry,'.'
  75.   LocStr      '.',Entry,1,DecLoc
  76. Label         Dec1
  77.   Length      CtrLgth,Entry                     ;align the decimal
  78.   Subtract    CtrLgth,DecLoc
  79.   Subtract    DecToAdd,CtrLgth
  80.   SetVar      Work,''
  81.   MidString   Work,Zeros,1,DecToAdd             ;get some zeros
  82.   Concat      Entry,Work                        ;add to units pos
  83.   Length      CtrLgth,Entry                     ;left space fill
  84.   SetVar      DecToAdd,19
  85.   Subtract    DecToAdd,CtrLgth
  86.   MidString   Work,Spaces,1,DecToAdd            ;get some spaces
  87.   Concat      Work,Work,Entry,Func              ;add to high order
  88.   Window1     58,1,80,25,240                    ;open our tape window
  89.   GoToXy      1,23                              ;  so we scroll
  90.   WriteLine   Work,240
  91.  
  92. Label     PrtTotal
  93.   SetVar      DecToAdd,NumDecs
  94.   LocStr      '.',Total,1,DecLoc                  ;force a decimal
  95.   Compare     DecLoc,0,TotDec
  96.   Concat      Total,'.'
  97.   LocStr      '.',Total,1,DecLoc
  98. Label     TotDec
  99.   Length      CtrLgth,Total                     ;align the decimal
  100.   Subtract    CtrLgth,DecLoc
  101.   Subtract    DecToAdd,CtrLgth
  102.   SetVar      Work,''
  103.   MidString   Work,Zeros,1,DecToAdd             ;get some zeros
  104.   Concat      Total,Work                        ;add to units pos
  105.   Length      CtrLgth,Total                     ;left space fill
  106.   SetVar      DecToAdd,19
  107.   Subtract    DecToAdd,CtrLgth
  108.   MidString   Work,Spaces,1,DecToAdd            ;get some spaces
  109.   Concat      Work,Work,Total,'='               ;add to high order
  110.   Window1     58,1,80,25,240                    ;open our tape window
  111.   GoToXy      1,23                              ;  so we scroll
  112.   WriteLine   Work,240
  113.   Window0     1,1,80,25                         ;full screen
  114.  
  115. Label     DispMem
  116.   Length      CtrLgth,Mem1                      ;left space fill
  117.   SetVar      DecToAdd,20
  118.   Subtract    DecToAdd,CtrLgth
  119.   MidString   Work,Spaces,1,DecToAdd            ;get some spaces
  120.   Concat      Work,Work,Mem1,' '               ;add to high order
  121.   WriteAt     4,6,Work,154
  122.   Length      CtrLgth,Mem2                     ;left space fill
  123.   SetVar      DecToAdd,20
  124.   Subtract    DecToAdd,CtrLgth
  125.   MidString   Work,Spaces,1,DecToAdd            ;get some spaces
  126.   Concat      Work,Work,Mem2,' '               ;add to high order
  127.   WriteAt     32,6,Work,154
  128.   Length      CtrLgth,Mem3                     ;left space fill
  129.   SetVar      DecToAdd,20
  130.   Subtract    DecToAdd,CtrLgth
  131.   MidString   Work,Spaces,1,DecToAdd            ;get some spaces
  132.   Concat      Work,Work,Mem3,' '               ;add to high order
  133.   WriteAt     4,11,Work,154
  134.   Length      CtrLgth,Mem4                     ;left space fill
  135.   SetVar      DecToAdd,20
  136.   Subtract    DecToAdd,CtrLgth
  137.   MidString   Work,Spaces,1,DecToAdd            ;get some spaces
  138.   Concat      Work,Work,Mem4,' '               ;add to high order
  139.   WriteAt     32,11,Work,154
  140.  
  141. Label     GetFunc
  142.   ClearBox    18,15,40,17,160
  143. Label     ShowTime
  144.   ?Time       Time                              ;get curr time
  145.   Cursor      Off
  146.   WriteAt     45,3,Time,228                     ;disp time
  147.   GoToXY      19,16
  148.   Cursor      Normal
  149.   Color       160
  150.   ReadKey     Func,Spec,1                       ;get our math function
  151.   Compare     Func,'',,,ShowTime                ;did we time out
  152.   Compare     Spec,'0',FuncKey                  ;was the key a special key
  153.   Compare     Func,Esc,,,EndPgm                 ;end the pgm
  154.   Compare     Func,Plus,,,CalcAdd               ;check the functions
  155.   Compare     Func,Minus,,,CalcMinus
  156.   Compare     Func,Mult,,,CalcMult
  157.   Compare     Func,Div,,,CalcDiv
  158.   Cursor      Off                               ;if we get here, invalid key
  159.   GoTo        GetFunc
  160. Label     FuncKey                               ;special key was entered
  161.   Compare     Func,F1,,,SetDecimals
  162.   Compare     Func,F2,,,ClearTot
  163.   Compare     Func,F3,,,ClearMem
  164.   Compare     Func,F4,,,RecallMem
  165.   Compare     Func,F5,,,AddMem
  166.   Compare     Func,F6,,,SubMem
  167.   Compare     Func,F7,,,StoreMem
  168.   GoTo        GetFunc
  169.  
  170. Label     CalcAdd
  171.   ReadStr     Entry
  172.   Add         Total,Entry,RtnCode,NumDecs       ;add to the total
  173.   Compare     RtnCode,0,,NextCalc,NextCalc
  174.   GoTo        MathErr
  175.  
  176. Label     CalcMinus
  177.   ReadStr     Entry
  178.   Subtract    Total,Entry,RtnCode,NumDecs       ;sub from the total
  179.   Compare     RtnCode,0,,NextCalc,NextCalc
  180.   GoTo        MathErr
  181.  
  182. Label     CalcMult
  183.   ReadStr     Entry
  184.   Multiply    Total,Entry,RtnCode,NumDecs       ;multiply total by entry
  185.   Compare     RtnCode,0,,NextCalc,NextCalc
  186.   GoTo        MathErr
  187.  
  188. Label     CalcDiv
  189.   ReadStr     Entry
  190.   Divide      Total,Entry,RtnCode,NumDecs       ;divide total by entry
  191.   Compare     RtnCode,0,,NextCalc,NextCalc
  192.   GoTo        MathErr
  193.  
  194. Label     SetDecimals
  195.   Cursor      Normal
  196.   Color       224
  197.   GoToXY      22,21                             ;find out how many decimals
  198.   Color       228
  199.   ReadStr     NumDecs
  200.   Cursor      Off
  201.   GoTo        GetFunc
  202.  
  203. Label     ClearTot
  204.   SetVar      Total,0
  205.   GoTo        PrtTotal
  206.  
  207. Label     ClearMem
  208.   SetVar      Mem1,0
  209.   SetVar      Mem2,0
  210.   SetVar      Mem3,0
  211.   SetVar      Mem4,0
  212.   GoTo        DispMem
  213.  
  214. Label     RecallMem
  215.   GoToXy      38,21
  216.   Color       228
  217.   ReadKey     Func                              ;which memory counter
  218.   Compare     Func,1,TryMRec2,GetFunc
  219.   SetVar      Total,0
  220.   SetVar      Entry,0
  221.   SetVar      Func,'R'                          ;so it shows as recall
  222.   SetVar      Entry,Mem1
  223.   Add         Total,Entry,RtnCode,NumDecs
  224.   Compare     RtnCode,0,,,NextCalc
  225.   GoTo        MathErr
  226. Label     TryMRec2
  227.   Compare     Func,2,TryMRec3
  228.   SetVar      Total,0
  229.   SetVar      Entry,0
  230.   SetVar      Func,'R'
  231.   SetVar      Entry,Mem2
  232.   Add         Total,Entry,RtnCode,NumDecs
  233.   Compare     RtnCode,0,,,NextCalc
  234.   GoTo        MathErr
  235. Label     TryMRec3
  236.   Compare     Func,3,TryMRec4
  237.   SetVar      Total,0
  238.   SetVar      Entry,0
  239.   SetVar      Func,'R'
  240.   SetVar      Entry,Mem3
  241.   Add         Total,Entry,RtnCode,NumDecs
  242.   Compare     RtnCode,0,,,NextCalc
  243.   GoTo        MathErr
  244. Label     TryMRec4
  245.   Compare     Func,4,GetFunc
  246.   SetVar      Total,0
  247.   SetVar      Entry,0
  248.   SetVar      Func,'R'
  249.   SetVar      Entry,Mem4
  250.   Add         Total,Entry,RtnCode,NumDecs
  251.   Compare     RtnCode,0,,,NextCalc
  252.   GoTo        MathErr
  253.  
  254.  
  255. Label     AddMem
  256.   GoToXy      38,21
  257.   Color       228
  258.   ReadKey     Func                              ;which memory counter
  259.   Compare     Func,1,TryMAdd2,GetFunc
  260.   Add         Mem1,Total,RtnCode,NumDecs
  261.   Compare     RtnCode,0,,,DispMem
  262.   GoTo        MathErr
  263. Label     TryMAdd2
  264.   Compare     Func,2,TryMAdd3
  265.   Add         Mem2,Total,RtnCode,NumDecs
  266.   Compare     RtnCode,0,,,DispMem
  267.   GoTo        MathErr
  268. Label     TryMAdd3
  269.   Compare     Func,3,TryMAdd4
  270.   Add         Mem3,Total,RtnCode,NumDecs
  271.   Compare     RtnCode,0,,,DispMem
  272.   GoTo        MathErr
  273. Label     TryMAdd4
  274.   Compare     Func,4,GetFunc
  275.   Add         Mem4,Total,RtnCode,NumDecs
  276.   Compare     RtnCode,0,,,DispMem
  277.   GoTo        MathErr
  278.  
  279. Label     SubMem
  280.   GoToXy      38,21
  281.   Color       228
  282.   ReadKey     Func                              ;which memory counter
  283.   Compare     Func,1,TryMSub2,GetFunc
  284.   Subtract    Mem1,Total,RtnCode,NumDecs
  285.   Compare     RtnCode,0,,,DispMem
  286.   GoTo        MathErr
  287. Label     TryMSub2
  288.   Compare     Func,2,TryMSub3
  289.   Subtract    Mem2,Total,RtnCode,NumDecs
  290.   Compare     RtnCode,0,,,DispMem
  291.   GoTo        MathErr
  292. Label     TryMSub3
  293.   Compare     Func,3,TryMSub4
  294.   Subtract    Mem3,Total,RtnCode,NumDecs
  295.   Compare     RtnCode,0,,,DispMem
  296.   GoTo        MathErr
  297. Label     TryMSub4
  298.   Compare     Func,4,GetFunc
  299.   Subtract    Mem4,Total,RtnCode,NumDecs
  300.   Compare     RtnCode,0,,,DispMem
  301.   GoTo        MathErr
  302.  
  303.  
  304. label     StoreMem
  305.   GoToXy      38,21
  306.   Color       228
  307.   ReadKey     Func                              ;which memory counter
  308.   Compare     Func,1,TryMStr2,GetFunc
  309.   SetVar      Mem1,0
  310.   Add         Mem1,Total,RtnCode,NumDecs
  311.   Compare     RtnCode,0,,,DispMem
  312.   GoTo        MathErr
  313. Label     TryMStr2
  314.   Compare     Func,2,TryMStr3
  315.   SetVar      Mem2,0
  316.   Add         Mem2,Total,RtnCode,NumDecs
  317.   Compare     RtnCode,0,,,DispMem
  318.   GoTo        MathErr
  319. Label     TryMStr3
  320.   Compare     Func,3,TryMStr4
  321.   SetVar      Mem3,0
  322.   Add         Mem3,Total,RtnCode,NumDecs
  323.   Compare     RtnCode,0,,,DispMem
  324.   GoTo        MathErr
  325. Label     TryMStr4
  326.   Compare     Func,4,GetFunc
  327.   SetVar      Mem4,0
  328.   Add         Mem4,Total,RtnCode,NumDecs
  329.   Compare     RtnCode,0,,,DispMem
  330.   GoTo        MathErr
  331.  
  332. Label     MathErr
  333.   Cursor      Off
  334.   Box1        2,21,55,23,48
  335.   WriteAt     22,21,' MATH  ERROR ',62
  336.   WriteAt     3,22,'Totals May be Damaged. Restart May Be Necessary.',52
  337.   WriteAt     22,23,'Press Any Key',62
  338.   ReadKey     Func
  339.   ClearBox    1,20,57,25,228                    ;msg box at bottom
  340.   WriteAt     3,21,Cmds1                        ;restore the box
  341.   WriteAt     3,22,Cmds2
  342.   WriteAt     3,23,Cmds3
  343.   WriteAt     3,24,Cmds4
  344.   SetVar      Entry,0
  345.   GoTo        NextCalc
  346.  
  347. Label     EndPgm
  348.   EnhanClr    Off
  349.   Cursor      On
  350.   Color       CurClr                            ;restore the orig color
  351.   Clear       CurClr
  352.